﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLK.Database.DALs;

namespace QLK.Database.BLLs
{
    public class CategoryBLL
    {
        private CategoryDAL dal;

        public CategoryBLL()
        {
            dal = new CategoryDAL();
        }

        public List<Category> Cate_GetAll()
        {
            return dal.Cate_GetAll();
        }

        public Category Cate_GetByID(int CateID)
        {
            if (CateID > 0)
                return dal.Cate_GetByID(CateID);

            return null;
        }

        public bool Cate_Insert(Category Cates)
        {
            if (dal.CategoryCheckDuplicateName(Cates.CategoryName))
                return dal.Cate_Insert(Cates);
            return false;
        }

        public bool Cate_DeleteByID(int CateID)
        {
            return dal.Cate_DeleteByID(CateID);

        }

        public bool Cate_UpdateByID(Category Cates)
        {
            if (dal.CategoryCheckDuplicateName(Cates.CategoryName))
                return dal.Cate_UpdateByID(Cates);
            return false;
        }
    }
}
